<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="DataTables/datatables.min.css"/>
<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>人员信息管理</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
	<span class="c-gray en">&gt;</span>
	业务管理
	<span class="c-gray en">&gt;</span>
	人员信息管理
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container" id="app">
	<div class="text-c">
		<form id="queryForm">
			<input type="text" name="name" id="query" placeholder="请输入员工姓名" style="width:250px" class="input-text" v-model="msg">
			<button class="btn btn-success" type="button" v-on:click="query()"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
		</form>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20">
		<a href="javascript:uploadReportXls();" class="btn btn-primary radius upload-btn r"><i class="Hui-iconfont">&#xe642;</i> 上传</a>
		<span class="btn-upload form-group r">
			<input class="input-text upload-url" type="text" name="uploadfile" id="uploadfile" readonly nullmsg="请添加附件！" style="width:200px">
			<a href="javascript:void();" class="btn btn-primary radius upload-btn"><i class="Hui-iconfont"></i> 浏览文件</a>
			<input type="file" multiple name="file" class="input-file" id="file">
		</span>
		<span class="l">
			<a href="javascript:;" onclick="staff_info_add('添加人员信息','3rd-staff-info-add.html','','510')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加人员信息</a>
		</span>
	</div>
	<div class="mt-20">
		<table id="list" class="table table-border table-bordered table-hover table-bg table-sort">
		</table>
	</div>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="DataTables/datatables.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="js/jquery.base64.js"></script>
<script type="text/javascript" src="js/vue.js" charset="utf-8"></script>
<script type="text/javascript">
/*上传文件*/
function uploadReportXls(){
	var formData = new FormData();
	formData.append("file", $("#file")[0].files[0]);
	$.ajax({
		url: ipAddress + '3rdpartyinfo/staffInfo/uploadReportXls',
		type:'POST',
		data: formData,
		contentType: false,
		processData: false,
		success:function(res){
			console.log(res.code);
			if(res.code=="1"){
				alert('成功');
			}else{
				alert('失败');
			}
		}
	});
}
/*第三方-人员信息-添加*/
function staff_info_add(title,url,w,h){
	layer_show(title,url,w,h);
}
/*第三方-人员信息-编辑*/
function staff_info_edit(title,url,id,w,h){
	layer_show(title,url + "?id=" + id,w,h);
}
/*第三方-人员信息-删除*/
function staff_info_del(obj,id){
	layer.confirm('确认要删除吗？',function(index){
		$.ajax({
			type: 'DELETE',
			url: ipAddress + '3rdpartyinfo/staffInfo/deleteStaffInfo',
			// url: ipAddress + 'auth/user/deleteUser',
			data: {
				id: id
			},
			beforeSend: function (request) {
				request.setRequestHeader("Authorization", "Bearer " + getToken());
			},
			dataType: 'json',
			success: function(data){
				$(obj).parents("tr").remove();
				layer.msg('已删除!',{icon:1,time:1000});
			},
			error:function(data) {
				console.log(data.msg);
			}
		});		
	});
}
</script>

<script type="text/javascript">
	var vm = new Vue({
		el : "#app",
		data : {
			msg : "",
			isAdmin : true
		},
		//在实例初始化之后，数据观测 (data observer) 和 event/watcher 事件配置之前被调用。
		beforeCreate:function(){
			console.log('beforeCreate');
		},
		/* 在实例创建完成后被立即调用。
		在这一步，实例已完成以下的配置：数据观测 (data observer)，属性和方法的运算，watch/event 事件回调。
		然而，挂载阶段还没开始，$el 属性目前不可见。 */
		created	:function(){
			console.log('created');
		},
		//在挂载开始之前被调用：相关的渲染函数首次被调用
		beforeMount : function(){
			console.log('beforeMount');
	
		},
		//el 被新创建的 vm.$el 替换, 挂在成功	
		mounted : function(){
			console.log('mounted');
		
		},
		//数据更新时调用
		beforeUpdate : function(){
			console.log('beforeUpdate');
				
		},
		//组件 DOM 已经更新, 组件更新完毕 
		updated : function(){
			console.log('updated');
				
		},
		methods: {
			query: function(){
				table.draw();
			}
		}
	});
	
	var table = $('#list').DataTable({
		language: {
			url: 'static/h-ui.admin/js/de_DE.txt'
		},
		//stateSave: true,
		"lengthMenu":[10, 50, 100],
		"pageLength": 100,
		searching: false,
		processing: true,
		serverSide: true,
		order: [[1, 'asc']],
		ajax: {
			 url: ipAddress + '3rdpartyinfo/staffInfo/getTablePage',
			//url: 'http://localhost:8000/vehicle/getTablePage',
			type: 'GET',
			data: function ( data ) {
				var param = {};
				var userInfo = getUserInfo();
				var page = data.start == 0 ? 0 : data.start / data.length;
				var size = data.length;
				var order = data.columns[data.order[0].column].data + " " + data.order[0].dir;
				param.draw = data.draw;
				param.page = page;
				param.size = size;
				param.like = '%name%';
				param.order = order;
				var formData = $("#queryForm").serializeArray();//把form里面的数据序列化成数组
				formData.forEach(function (e) {
					console.log(e.value == '');
					// if(e.value){
						param[e.name] = e.value;
					// }
				});
				if(hasRole('COMPANY')){
					vm.isAdmin = false;
				}
				return param;
			}
		},
		columns: [
			{title: '工号', name: 'id', data: 'id', defaultContent: '无'},
			{title: '分公司', name: 'companyname', data: 'company.companyname', defaultContent: '无'},
			{title: '姓名', name: 'name', data: 'name', defaultContent: '无'},
			{title: '性别', name: 'sex', data: 'sex', defaultContent: '无',
				render: function(data, type, row, meta) {
					return row.sex == 0 ? '女' : '男';
				}
			},
			{title: '手机', name: 'phoneNo', data: 'phoneNo', defaultContent: ''},
			// {title: '照片', name: 'photoUrl', data: 'photoUrl', defaultContent: '',
			// 	render: function(data, type, row, meta) {
			// 		return '<img src="' + row.photoUrl + '"/>';
			// 	}
			// },
			{title: '合同终止日期', name: 'contractEndDate', data: 'contractEndDate', defaultContent: ''},
			{title: '录入日期', name: 'createTime', data: 'createTime', defaultContent: ''},
			{title: '操作', name: 'operation', defaultContent: '',
				render: function(data, type, row, meta) {
					var operations;
					var op_edit = "<a title=\"编辑\" href=\"javascript:;\" onclick=\"staff_info_edit('编辑','3rd-staff-info-update.html','" + row.id + "','','510')\" class=\"ml-5\" style=\"text-decoration:none\"><i class=\"Hui-iconfont\">&#xe6df;</i></a>";
					var op_del = "<a title=\"删除\" href=\"javascript:;\" onclick=\"staff_info_del(this,'" + row.id + "')\" class=\"ml-5\" style=\"text-decoration:none\"><i class=\"Hui-iconfont\">&#xe6e2;</i></a>";
					operations = op_edit + op_del;
					return operations;
				}
			}
		],
		columnDefs: [
			{"orderable":false,"targets":[7]}
		]
	});
</script>
</body>
</html>